import request from "@/utils/request.js";

/**
 * 上传文章
 * @param {Object} data
 */
export const editArticle = function(data) {
	return request.post(
		"article/edit",
		data
	);
}

/**
 * 获取首页推荐文章
 * @param {Object} data
 */
export const getRecommandArticle = function(data) {
	return request.get(
		"article/recommand",
		data,
		{
			noAuth: true
		}
	);
}

/**
 * 根据id获取文章详情
 * @param {Object} id
 */
export const getArticleDetails = function(id) {
	return request.get(
		`article/${id}`
	)
}

/**
 * 根据文章id获取文章评论
 * @param {Object} id 文章id
 * @param {Object} data 分页数据
 */
export const getArticleComment = function(id, data) {
	return request.get(
		`article/comment/${id}`,
		data
	);
}

/**
 * 评论文章
 * @param {Object} data
 */
export const commentArticle = function(data) {
	return request.post(
		"article/edit/comment",
		data
	);
}

/**
 * 回复评论
 * @param {Object} data
 */
export const replyComment = function(data) {
	return request.post(
		"article/edit/reply",
		data
	);
}

/**
 * 获取相应文章相应楼层更多回复
 * @param {Object} articleId
 * @param {Object} floorId
 * @param {Object} data
 */
export const getMoreReply = function(articleId, floorId, data) {
	return request.get(
		`article/reply/${articleId}/${floorId}`,
		data
	);
}

/**
 * 点赞文章
 * @param {Object} data
 */
export const toLike = function(data) {
	return request.post(
		'article/like',
		data
	);
}

/**
 * 点赞文章
 * @param {Object} data
 */
export const toCollect = function(data) {
	return request.post(
		'article/collect',
		data
	);
}